package com.titar.robot.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreUtils {
    private static SharedPreUtils instence;
    private SharedPreferences sp;

    private SharedPreUtils(Context context) {
        sp = context.getSharedPreferences("robot", Context.MODE_PRIVATE);
    }

    public static SharedPreUtils getInstence(Context context) {
        synchronized (SharedPreUtils.class) {
            if (instence == null) {
                instence = new SharedPreUtils(context);
            }
        }
        return instence;
    }

    public String getToken() {
        return sp.getString("accesstoken", "");
    }

    public boolean isFirst() {
        return sp.getBoolean("isfirst", true);
    }

    public void setToken(String token) {
        sp.edit().putString("accesstoken", token).commit();
    }

    public void setIsFirst() {
        sp.edit().putBoolean("isfirst", false).commit();
    }
}
